package class06;



/**
 * @Auther: xw
 * @Create: 2022/3/25 14:58
 * @Description: 判断；两棵树是不是相等
 */
public class SameTree {
    public static class TreeNode {
        public int val;
        public TreeNode left;
        public TreeNode right;
    }

    public static boolean isSameTree(TreeNode p , TreeNode q){
        if(p == null ^ q == null){
            return false;
        }
        if (p == null && q == null) {
            return true;
        }
        return p.val == q.val && isSameTree(p.left,q.left) && isSameTree(p.right,q.right);
    }
}
